<?xml version="1.0" encoding="UTF-8"?>

<!-- Copyright 2007 XBRL International. All Rights Reserved. -->

<link:linkbase
  xmlns:xlink="http://www.w3.org/1999/xlink"
  xmlns:link="http://www.xbrl.org/2003/linkbase"
  xmlns:generic="http://xbrl.org/2008/generic"
  xmlns:formula="http://xbrl.org/2008/formula"
  xmlns:variable="http://xbrl.org/2008/variable"
  xmlns:cf="http://xbrl.org/2008/filter/concept"
  xmlns:gf="http://xbrl.org/2008/filter/general"
  xmlns:pf="http://xbrl.org/2008/filter/period"
  xmlns:xfi="http://www.xbrl.org/2008/function/instance" 
  xmlns:xfi-ext="http://www.xbrl.org/2008/function/instance/extension" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xs="http://www.w3.org/2001/XMLSchema" 
  xmlns:test="http://abc.com/test"
  xmlns:xbrli="http://www.xbrl.org/2003/instance"

  xsi:schemaLocation="
  http://www.xbrl.org/2003/linkbase http://www.xbrl.org/2003/xbrl-linkbase-2003-12-31.xsd
  http://xbrl.org/2008/generic ../../core_schemas/generic-link.xsd
  http://xbrl.org/2008/formula ../../core_schemas/formula.xsd
  http://xbrl.org/2008/variable ../../core_schemas/variable.xsd
  http://xbrl.org/2008/filter/concept ../../core_schemas/concept-filter.xsd
  http://xbrl.org/2008/filter/period ../../core_schemas/period-filter.xsd
  http://xbrl.org/2008/filter/general ../../core_schemas/general-filter.xsd
  ">
  
  <link:arcroleRef arcroleURI="http://xbrl.org/arcrole/2008/variable-set" xlink:href="../../core_schemas/variable.xsd#variable-set" xlink:type="simple"/>
  <link:arcroleRef arcroleURI="http://xbrl.org/arcrole/2008/variable-filter" xlink:href="../../core_schemas/variable.xsd#variable-filter" xlink:type="simple"/>
  <link:roleRef roleURI="http://www.xbrl.org/2008/role/link" xlink:href="../../core_schemas/generic-link.xsd#standard-link-role" xlink:type="simple"/>

  <generic:link xlink:type="extended"
    xlink:role="http://www.xbrl.org/2008/role/link">

    <formula:formula xlink:type="resource" xlink:label="formula" 
      value="sum($children)"
      source="parent"
      aspectModel="non-dimensional" implicitFiltering="true">
      <formula:decimals>0</formula:decimals>
    </formula:formula>

    <!-- function xfi:navigate-relationships -->
    <variable:function xlink:type="resource" xlink:label="navigate-relationships"
       name="xfi:navigate-relationships"
       output="xs:anyAtomicType*">
         <!-- source concept to begin navigation -->
         <variable:input type="xs:QName" />
         <!-- link role -->
         <variable:input type="xs:anyURI" />
         <!-- arc role -->
         <variable:input type="xs:anyURI" />
         <!-- axis (child, parent, etc) -->
         <variable:input type="xs:string" />
         <!-- generations limit or zero for unlimited -->
         <variable:input type="xs:integer" />
    </variable:function>

    <!--  Fact variables.  Note that no general variables are used in this formula. -->
    <variable:factVariable xlink:type="resource" xlink:label="v_parent"   bindAsSequence="false" />
    <variable:factVariable xlink:type="resource" xlink:label="v_children"   bindAsSequence="true" />

    <!--  Arc from the formula to the variables it depends on -->
    <variable:variableArc xlink:type="arc" xlink:arcrole="http://xbrl.org/arcrole/2008/variable-set" 
      xlink:from="formula" xlink:to="v_parent" order="1.0"
      name="parent" />
    <variable:variableArc xlink:type="arc" xlink:arcrole="http://xbrl.org/arcrole/2008/variable-set" 
      xlink:from="formula" xlink:to="v_children" order="1.0"
      name="children" />
    <!--  Arcs from variables to their concept filters -->
    <variable:variableFilterArc xlink:type="arc" xlink:arcrole="http://xbrl.org/arcrole/2008/variable-filter" 
      complement="false" cover="true"
      xlink:from="v_children" xlink:to="f_children" order="1.0"/>

    <!-- test that children are in the node names list from the naviagtion function -->
    <gf:general xlink:type="resource" xlink:label="f_children"
     test="exists(index-of($rels, node-name()))" />

    <!-- cover concept aspect to allow child facts to bind -->
    <cf:conceptSubstitutionGroup strict="false" xlink:type="resource" xlink:label="f_children">
      <cf:substitutionGroup><cf:qname>xbrli:item</cf:qname></cf:substitutionGroup>
    </cf:conceptSubstitutionGroup>

    <!-- general variable is sequence of children (QName, arc-attributes)* -->
    <variable:generalVariable xlink:type="resource" xlink:label="rels" bindAsSequence="true"
      select="xfi:navigate-relationships(
                node-name($parent), 
                'http://abc.com/role/link1',
                'http://abc.com/arcrole/def-test',
                'descendant',
                2)"  />
    <variable:variableArc xlink:type="arc" xlink:arcrole="http://xbrl.org/arcrole/2008/variable-set" 
      xlink:from="formula" xlink:to="rels" order="1.0"
      name="rels" />

  </generic:link>

</link:linkbase>
